< previous page page_810 next page >

Page 810
Listing C.12ANDOR.TXTCombining Multiple WHERE Conditions with AND or OR
'********************************
'Find all Smiths in the Southeast
'********************************
SELECT * FROM Customers WHERE Lastname = 'Smith' AND   _
    State IN ('AL', 'FL', 'GA')
'**************************************************
'Find all occurrences of Scott in first or last name
'**************************************************
SELECT * FROM Customers WHERE Lastname = 'Scott' _
     OR Firstname = 'Scott'
0810-01.jpg
Figure C.6
You can use multiple conditions to enhance a 
WHERE clause.
Setting the Sort Conditions
In addition to specifying the range of records to process, you can also use the SELECT statement to specify the order in which you want the records to appear in the output dynaset. The SELECT statement controls the order in which the records are processed or viewed. Sorting the records is done by using the ORDER BY clause of the SELECT statement.
You can specify the sort order with a single field or with multiple fields. If you use multiple fields, the individual fields must be separated by commas.
The default sort order for all fields is ascending (that is, A-Z, 09). You can change the sort order for any individual field by specifying the DESC keyword after the field name (the DESC keyword affects only the one field, not any other fields in the ORDER BY clause). Listing C.13 shows several uses of the ORDER BY clause. Figure C.7 shows the results of these SELECT statements.

 
< previous page page_810 next page >